@extends('layouts.forum')

@section('title', '编辑主题')

@section('css')
@endsection

@section('contaier')
    @if (session('_error'))
        <div class="alert alert-danger">
            <a href="#" class="close" data-dismiss="alert">&times;</a>
            <strong>通知：</strong>{{session('_error')}}
        </div>
    @endif
    <div class="topic_create">
        <div class="col-md-8 main-col">
            <div class="reply-box form box-block">
                <form method="POST" action="{{url('/topic/update')}}" accept-charset="UTF-8" id="topic-create-form">
                    {{csrf_field()}}
                    <input type="hidden" name="id" value="{{$topic->id}}">
                    <div class="form-group">
                        <label for="partition-select" class="hidden"></label>
                        <select class="selectpicker form-control" name="partition_id" id="partition-select" required>
                            <option value="{{$topic->pid or 0}}" selected>{{$topic->partition->display_name}}</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="category-select" class="hidden"></label>
                        <select class="selectpicker form-control" name="category_id" id="category-select" required>
                            @foreach($topic->partition->partitionCategorie()->get() as $item)
                                <option value="{{$item->categorie->id}}"  {{$item->categorie->id == $topic->category_id ? 'selected' : ''}}>{{$item->categorie->name}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="form-group">
                        <input class="form-control" id="topic-title" placeholder="请填写标题" name="title" type="text" value="{{$topic->title or ''}}" required>
                    </div>
                    <div id="reply_notice" class="box">
                        @include('include.topic.tips')
                    </div>
                    <div class="form-group">
                        <label for="reply_content" class="hidden"></label>
                        <input type="file" class="hidden" id="uploadImg">
                        <textarea class="form-control" rows="20" id="reply_content" name="reply_content" cols="20">{{$topic->body_original or ''}}</textarea>
                    </div>
                    <div class="form-group status-post-submit">
                        <input class="btn btn-primary" id="topic-create-submit" type="submit" value="保存">
                    </div>
                    <div class="box preview markdown-body" id="preview-box"></div>
                </form>
            </div>
        </div>
        <div class="col-md-4 side-bar">
            @include('include.topic.ruls')
        </div>
    </div>
@endsection

@section('js')
    <script>
        var fieldName   = null;
        var body        = $('body');
        $(document).ready(function () {
            body.css("background-color", "whitesmoke");
            body.css("height", "10px");
            $('.popover-with-html').hover(function () {
                $('.popover-with-html').popover({
                    html : true,
                    trigger : 'hover',
                    container: 'body',
                    placement: 'auto top'
                });
            });
        });
    </script>
@endsection